<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/8/14 0014
 * Time: 17:43
 */

namespace app\outstockentry\model;

use think\Db;

class Index extends \CompanyModel {


    public function getoutstockentry(){

        return Db::connect($this->connection)->name("sal_outstock")->order('FBILLNO desc')->limit(1)->select();
       // return Db::connect($this->connection)->name("accessory")->order('accessory_id desc')->limit(1)->select();
    }

    public function addOutstock($data){
        return Db::connect($this->connection)->name("sal_outstock")->insertGetId($data);
        // return Db::connect($this->connection)->name("accessory")->order('accessory_id desc')->limit(1)->select();
    }
   // insertAll
    public function addOutstockentry($data){
        return Db::connect($this->connection)->name("sal_outstockentry")->insertAll($data);
        // return Db::connect($this->connection)->name("accessory")->order('accessory_id desc')->limit(1)->select();
    }

    //删除销售出库单  主表
    public function delOutstock($id){
        return Db::connect($this->connection)->name("sal_outstock")->where('FID',$id)->delete();
    }

    //删除销售出库单  主表
    public function delOutstockentry($id){
        return Db::connect($this->connection)->name("sal_outstockentry")->where('FID',$id)->delete();
       // return Db::connect($this->connection)->name("sal_outstockentry")->where('FENTRYID',$id)->delete($id)->getlast;
    }

    public function getlist(){
       // $data =  Db::connect($this->connection)->name("sal_outstock")->select();
        $data =  Db::connect($this->connection)->name("sal_outstock")->limit(2)->select();
        foreach ($data as $k=>$v){
            $data[$k]['datalist'] =  Db::connect($this->connection)->name("sal_outstock")->where('FID',$v['FID'])->select();
        }
        return $data;
    }

}